<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Replace cached inserts with the actual results
 *
 * @param string $results
 * @return string
 */
function smarty_insert_account($params, &$smarty) {
	//global $pObj;
	
	//
	//$_SESSION['vh']->add($product['products_id'], 'p');
	//$vh_products = $pObj->getProducts(array('ids' => $_SESSION['vh']->get('p')));
	if( $smarty->caching == 1 ) {
		$smarty->caching = 0;
		//
		//$cart_products = $_SESSION['cart']->getProducts();
		//$cart_total = $_SESSION['cart']->getTotal();
		//$smarty->set_vars_content('cart', array('products' => $cart_products, 'total' => $cart_total));
		
		if( isset($_COOKIE['_unp']) ) {
			$smarty->set_vars_context('account_username', $_COOKIE['_un']);
			$smarty->set_vars_context('account_password', $_COOKIE['_up']);
			$smarty->set_vars_context('account_rememberme', 1);
		}
		//
		$content = $smarty->fetch($params['file']);
		$smarty->caching = 1;
	} else {
		$content = $smarty->fetch($params['file']);
	}
	//
	if( isset($params['type']) ) {
		$content = '<div id="account_' . $params['type'] . '">' . $content . '</div>';
	}
	
	return $content;
}
//
?>